#include "common.h"

volatile struct dma_reg *dma1 = (volatile struct dma_reg *)0x40020000;

#pragma pack(4)
volatile unsigned int adc_dma_buf[ADC_DMA_BUF_NUM][ADC_CHANNEL_NUM];
#pragma pack()

void init_dma_var(void)
{
    memory_set((void *)adc_dma_buf, 0, sizeof(adc_dma_buf));
}

void init_dma1(void)
{
    dma1 = (volatile struct dma_reg *)0x40020000;
    rcc->AHBENR |= (1 << 0);
    dma1->channel[0].CCR   = 0x3aa0;
    dma1->channel[0].CPAR  = 0x4001244c;
    dma1->channel[0].CMAR  = (unsigned int)adc_dma_buf;
    dma1->channel[0].CNDTR = ADC_CHANNEL_NUM * ADC_DMA_BUF_NUM;
    dma1->channel[0].CCR |= (1 << 0);
}
